<?php
/**
 * NAME: wiki
 * WHEN: OnMsg
 * PROVIDES: !wiki !nonsens
 * AUTOLOAD: true
 * DESCRIPTION: Pobiera poczatek artykulu z wikipedii.:)
 * VERSION: 0.1
 * UPDATE: http://update.tempaq2.blacksoft.eu/check.php
 */
 
exit();

//*function_start
 if ($d[0]=='!wiki'||$d[0]=='!nonsens') {
 	if ($d[1]=='help') {
 		$bot->send_text('wiki_help');
 	} else {
 		$message = substr($data->message, strlen($d[0])+1);
 		$message = str_replace(' ', '_', $message);
 		$message = urlencode($message);
 		switch ($d[0]) {
 			case '!wiki':
 				 $strona = 'http://'.$lang->text('wiki_lang').'.wikipedia.org/wiki/'.$message;
 				 break;
 			case '!nonsens':
 				 $strona = 'http://nonsensopedia.wikia.com/wiki/'.$message;
 				 break;
 		}
 		$strona = @file_get_contents($strona);
 		$strona = substr($strona, strpos($strona, '<!-- start content -->')+strlen('<!-- start content -->'), strpos($strona, '<!-- end content -->')-strpos($strona, '<!-- start content -->'));
 		$strona = substr($strona, strpos($strona, '<p>')+3);
 		$strona = eregi_replace('<table.*>.*<\/table>', '', $strona);
 		$strona = ereg_replace('\[.*\]', '', $strona);
 		$strona = eregi_replace('<script.*>.*<\/script>', '', $strona);
 		$strona = ereg_replace("[\n]+", ' ', $strona);
 		$strona = strip_tags($strona);

 		$strona = $bot->my_iconv('bez-ogonkow', substr(trim(html_entity_decode($strona)), 0, 400)."...");
 		$bot->send($strona);
 	}
 } elseif ($d[0] == '!wikilink') {
 	$message = substr($data->message, strlen($d[0])+1);
 	$message = str_replace(' ', '_', $message);
 	$message = urlencode($message);
 	$bot->send('http://'.$lang->text('wiki_lang').'.wikipedia.org/wiki/'.$message);
 }
//*function_end
?>